package com.xzzz.irda.auth.core.filter;

import com.xzzz.irda.auth.core.AuthBaseConfiguration;
import com.xzzz.irda.auth.core.filter.impl.*;
import com.xzzz.irda.auth.core.permission.PermAuthAspect;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 拦截器配置控制
 *
 * @author wangyf
 * 
 */
@Slf4j
@Configuration
public class AuthBaseFilterConfiguration {

    /**
     * 注入代理过滤器
     * @param authBaseConfiguration 全局配置
     * @return 代理过滤器
     */
    @Bean
    public AuthFilterProxy authFilterProxy (AuthBaseConfiguration authBaseConfiguration) {
        return new AuthFilterProxy(authBaseConfiguration);
    }

    /**
     * 请求封装过过滤器
     * @return 过滤器
     */
    @Bean
    public RequestWrapperFilter requestWrapperFilter () {
        return new RequestWrapperFilter();
    }

    /**
     * 请求日志过滤器
     * @return 过滤器
     */
    @Bean
    public RequestLogFilter logFilter () {
        return new RequestLogFilter();
    }

    /**
     * 白名单过滤器
     * @return 过滤器
     */
    @Bean
    public WhiteListFilter whiteListFilter () {
        return new WhiteListFilter();
    }

    /**
     * 授权校验过滤器
     * @return 过滤器
     */
    @Bean
    public AuthorizationValidateFilter authorizationValidateFilter () {
        return new AuthorizationValidateFilter();
    }

    /**
     * 授权校验过滤器
     * @return 过滤器
     */
    @Bean
    public AuthorizationUniqueFilter authorizationUniqueFilter () {
        return new AuthorizationUniqueFilter();
    }

    /**
     * 令牌刷新过滤器
     * @return 过滤器
     */
    @Bean
    public TokenExpireResetFilter tokenExpireResetFilter () {
        return new TokenExpireResetFilter();
    }

    /**
     * 细粒度权限拦截切面
     * @return 过滤器
     */
    @Bean
    public PermAuthAspect permCheckAspect () {
        return new PermAuthAspect();
    }

}
